﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using DotNetNuke.ComponentModel.DataAnnotations;
using DotNetNuke.Data;

namespace DotNetNuke.Modules.mwOrgChart.Components.Business
{

    public enum HierarchyStatus
    {
        Disabled,
        Active,
        Pending
    }

    [TableName("mwHierarchies")]
    [PrimaryKey("NodeID")]
    public class mwHierarchy
    {
        public int NodeID { get; set; }
        public int HierarchyID { get; set; }
        public int ParentID { get; set; }
        public string Name { get; set; }       
        public string Shortname { get; set; }
        public int NodeOrder { get; set; }
        public HierarchyStatus Status { get; set; }
        public int Level { get; set; }

        [IgnoreColumn]
        public IEnumerable<mwHierarchy> Children { get; set; }

        [IgnoreColumn]
        public int CildrenCount
        {
            get
            {
                return this.Children.Count();               

            }
        }

        [IgnoreColumn]
        public bool HasChildren
        {
            get { return this.Children.Count() > 0; }
        }

        ///<summary>
        /// An integer for the user id of the user who created the object
        ///</summary>
        [IgnoreColumn]
        public int CreatedByUserId { get; set; }

        ///<summary>
        /// An integer for the user id of the user who last updated the object
        ///</summary>
        [IgnoreColumn]
        public int LastModifiedByUserId { get; set; }

        ///<summary>
        /// The date the object was created
        ///</summary>
        [IgnoreColumn]
        public DateTime CreatedOnDate { get; set; }

        ///<summary>
        /// The date the object was updated
        ///</summary>
        [IgnoreColumn]
        public DateTime LastModifiedOnDate { get; set; }
        
    }
}